package com.example.armmvvm.ui.audio

import android.os.Bundle
import com.example.arm.base.BaseActivity
import com.example.armmvvm.databinding.ActivityAudioBinding
import java.io.File

/**
 *
 * 包名：com.example.armmvvm.ui.audio
 * 文件描述：
 * 创建人：yanghaozhang
 * 创建时间：2023/1/20 19:49
 * 修改人：
 * 修改时间：
 * 修改备注：
 * @Version:1.0
 */
class AudioActivity : BaseActivity<ActivityAudioBinding>() {

    private var recorder: AudioRecorder? = null

    override fun initView(savedInstanceState: Bundle?): ActivityAudioBinding {
        return ActivityAudioBinding.inflate(layoutInflater)
    }

    override fun initData(savedInstanceState: Bundle?) {
        binding.apply {
            tvStart.setOnClickListener {
                recorder = AudioRecorder(this@AudioActivity)
                val file = File(externalCacheDir?.absolutePath, "audio11.mp3")
                recorder?.startRecord(file.absolutePath)
            }
            tvEnd.setOnClickListener {
                recorder?.stopRecord()
            }
        }
    }
}